package database

import (
	. "hxy/repo/model"
	"log"

	"github.com/google/uuid"
	"gorm.io/gorm"
)

// #region crud for gitmodel
func CreateGitMonitor(gi GitMonitorInter) (GitMonitorInter, *gorm.DB) {
	re := Db.Create(gi)
	return gi, re
}
func GetAllGitMonitor() ([]GitMonitorInter, *gorm.DB) {
	var gitAll []GitMonitorInter
	re := Db.Find(&gitAll)
	return gitAll, re
}
func GitMonitorByuuid(id uuid.UUID) (GitMonitorInter, *gorm.DB) {
	var gitrepo GitMonitorInter
	re := Db.Where("UUID = ?", id.String()).Find(&gitrepo)
	return gitrepo, re
}
func GitMonitorDeleteId(id uuid.UUID) (re *gorm.DB) {
	return Db.Delete(&GitMonitorInter{
		UUID: id.String(),
	})
}
func ChangeMonitorStatue(gi GitMonitorInter) (tx *gorm.DB) {
	log.Printf("change status ,%s ", gi.Status)
	return Db.Model(&gi).Update("status", gi.Status)
}

//#endregion
